/**
 * 获取对象的全部静态属性
 * Reflect.ownKeys() = Object.getOwnPropertyNames() + Object.getOwnPropertySymbols()
 *
 * Reflect.ownKeys() 获取普通属性、不可枚举属性、Symbol属性
 * Object.getOwnPropertyNames() 获取普通属性、不可枚举属性
 * Object.getOwnPropertySymbols() 获取不可枚举属性、Symbol属性
 */
const symbolSay = Symbol.for('say1');

class Person {
  static flag = '人';
  static getFlag() {
    return Person.flag;
  }

  static [Symbol.for('symbolPro')]() {
    return 'symbolPro';
  }

  constructor(name) {
    this.name = name;
    this[symbolSay] = 'haha';
  }

  getName() {
    return this.name;
  }
  getAge = () => {
    return 15;
  };
}

function getOwnPropertyStatics(_obj) {
  const KNOWN_STATICS = {
    name: true,
    length: true,
    prototype: true,
    caller: true,
    callee: true,
    arguments: true,
    arity: true,
  };

  let result = [];
  let keys = Object.getOwnPropertyNames(_obj);
  keys = keys.concat(Object.getOwnPropertySymbols(_obj));
  //   const keys = Reflect.ownKeys(_obj);
  console.log('origin keys: ', keys);
  for (let i = 0; i < keys.length; i++) {
    const key = keys[i];
    if (!KNOWN_STATICS[key]) {
      result.push(key);
    }
  }
  return result;
}

console.log(getOwnPropertyStatics(Person));
